package voloshyn.paliy.ui;

import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.ArrayAdapter;

public class BluetoothScanDevices extends BroadcastReceiver {
    private ArrayAdapter<String> adapter;
    public BluetoothScanDevices(ArrayAdapter<String> theAdapter)
    {
	adapter=theAdapter;
    }
    @Override
    public void onReceive(Context arg0, Intent intent) {
	String action = intent.getAction();
	if (action.equals(BluetoothDevice.ACTION_FOUND)) {
	    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
	    String str = device.getName() + "\t" + device.getAddress();
	    adapter.add(str);
	    adapter.notifyDataSetChanged();
	}
    }
}
